home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
CRON_1
/
STANDARD
/
TRAP_UTI.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-10
|
970b
|
62 lines
#include "Trap Util.h"
/* All of this code comes directly from IM VI pg. 3-8. */
#define _Unimplemented 0xA89F
#define _InitGraf 0xA86E
int NumToolboxTraps(void);
TrapType GetTrapType(int theTrap);
Boolean TrapAvailable(int theTrap);
int NumToolboxTraps() {
int NumToolboxTraps;
if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E, ToolTrap))
NumToolboxTraps = 0x200;
else
NumToolboxTraps = 0x400;
return (NumToolboxTraps);
}
TrapType GetTrapType(theTrap)
int theTrap;
{
TrapType tType;
if ((theTrap & 0x0800) > 0)
tType = ToolTrap;
else
tType = OSTrap;
return (tType);
}
Boolean TrapAvailable(theTrap)
int theTrap;
{
TrapType tType;
tType = GetTrapType(theTrap);
if (tType == ToolTrap) {
theTrap &= 0x07FF;
if (theTrap >= NumToolboxTraps())
theTrap = _Unimplemented;
}
return (NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap));
}